package com.ph.demo.jvm;

import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
import java.util.Random;

/**
 * Created by peng on 2019/4/25.
 */
public class TestGC {
    //不断产生新的对象，随机的废弃对象
    public static void main(String[] args) throws InterruptedException {

        List<Object> objects = new ArrayList<>();

        while (true){

            int sleep = new Random().nextInt(100);

            if (System.currentTimeMillis() % 2 ==0){
                objects.clear();
            }else{
                for (int i = 0; i <10000 ; i++) {
                    Properties properties = new Properties();
                    properties.put("key_"+i,"value_"+i);
                    objects.add(properties);
                }
            }
            Thread.sleep(sleep);
        }

    }

}
